package de.mhu.mandalaui.list;

import de.mhu.mandalaui.Response;
import de.mhu.mandalaui.StyleUtil;
import de.mhu.mandalaui.TextComposit;
import de.mhu.mandalaui.table.AbstractTable;
import de.mhu.mandalaui.text.Paragraph;
import de.mhu.mandalaui.text.Text;

public class ListItem extends TextComposit {

	public ListItem() {
		super();
	}

	public ListItem(Text... components) {
		super(components);
	}

	public ListItem(String heading, String text) {
		super(StyleUtil.appendClass(new Text(Text.TYPE.H4, heading), "list-group-item-heading"),
				StyleUtil.appendClass(new Paragraph(text), "list-group-item-text") );
	}
	
	public String getStyleBase() {
		return "list-group-item";
	}

	@Override
	public void render(Response response) {

		super.render(response);
	}
	
	public void checkSelectableAction() {
		if (getClickAction() == null && getParent() != null && (getParent() instanceof SelectableList) ) {
			SelectableList table = (SelectableList)getParent();
			if (table.getSelectAction() != null) {
				setClickAction(table.getSelectAction());
			}
		}
		
	}
}
